package rhinestone.TUI;

import java.util.Scanner;
import java.util.InputMismatchException;

import rhinestone.Model.Staff;

/**
 * Abstract UI class, which is extended by all UI classes, except MainMenuUI,
 * which holds the reference to all the UIs.
 * @author Group 2
 * @version 2010.12.15
 */
public abstract class UI {
	protected final String BARCODE_MESSAGE = "Item barcode: ";
	protected final String CPR_MESSAGE = "CPR: ";
    protected final String NAME_MESSAGE = "Name: ";
    protected final String ADDRESS_MESSAGE = "Address: ";
    protected final String PHONE_MESSAGE = "Phone number: ";
	protected final String AMOUNT_MESSAGE = "Amount: ";

	protected abstract void startMenu();
	protected abstract void printMenu();

	/**
	 * Prompt method which asks the user to choose the menu option.
	 * @return Choice the user has inputed.
	 */
	protected int promptChoiceInput() {
		System.out.print("Your choice: ");
		int choice = new Scanner(System.in).nextInt();
		return choice;
	}

	/**
	 * Prompt methods which ask the user for an input.
	 * Can be done with some sort of scanner or buy hand.
	 * Each method asks for different type of input: String, double and int.
	 *
	 * @param message The message the user should see when asked for the input (use one of the final String variables in abstract UI class).
	 * @return The entered input.
	 */
	protected String promptStringInput(String message) {
		System.out.print(message);
		String input = new Scanner(System.in).nextLine();
		return input;
	}

	protected double promptDoubleInput(String message) {
		System.out.print(message);
		double input = 0;
		try {
			input = new Scanner(System.in).nextDouble();
		} catch(InputMismatchException ex) {
			System.err.println("Digits separated with period '.' are allowed only.");
			System.err.println("Try again.");
			promptDoubleInput(message);
		}
		return input;
	}

	protected int promptIntInput(String message) throws InputMismatchException {
		System.out.print(message);
		int input = 0;
		try {
			input = new Scanner(System.in).nextInt();
		} catch(InputMismatchException ex) {
			System.err.println("Integers are allowed only.");
			System.err.println("Try again.");
		}
		return input;
	}

	protected Staff validateEmployee(String cpr, String psw) {
		return null;
	}
}
